<template>
  <div class="goods-list">
    <el-row style="margin-bottom:15px">
      <el-button type="primary" @click="nav('add')">新增会员等级</el-button>
    </el-row>
    <sx-common-table :data="list" :columns="columns" :isCheckbox="true" max-height="700" :border="false" @bntClick="btnClick">
      <el-table-column prop="cover" label="封面" align="center" :width="160">
				<template slot-scope="scope">
					<div>
						<img :src="scope.row.cover" class="cover">
					</div>
				</template>
			</el-table-column>
    </sx-common-table>
  </div>
</template>

<script>
import SxCommonTable from "@/components/SxCommonTable"
export default {
  components: {
    SxCommonTable,
  },
  data() {
    return {
      list: [],
      columnsOld:[
				{label:"商品编号",value:"id"},
				{label:"商品名称",value:"goodsName"},
				{label:"价格",value:"price"},
				{label:"划线价",value:"linePrice"},
				{label:"库存",value:"num"},
				{label:"规格",value:"size"},
      ],
      columns:[
        {label:"商品编号",prop:"id",width:120},
				{label:"商品名称",prop:"goodsName",isLongText:true,isTextCut:true},
				{label:"价格",prop:"price",isPrice:true,width:140},
				{label:"划线价",prop:"linePrice",isPrice:true,width:140},
				{label:"库存",prop:"num",isPrice:true,width:140},
        {label:"规格",prop:"size",isTextCut:true,width:200},
        {label:"操作",btn:[{name:"删除",type:"danger"},{name:"编辑",type:"primary"}],width:160}
      ]
    };
  },
  created() {
    //let tab=[{name:'商品管理',path:'goodsList'}];
    //this.$store.commit('_setTab',tab);
    this.getData();
  },
  methods: {
    btnClick(e){
       console.log(this)
      console.log(e)
     
      this.$router.push({
          path: 'goodsEdit?id='+e.row.id
        });
    },
    nav(path) {
      this.$router.push({
        path: path
      });
    },
    getData() {
      this.$api.goodsList().then(res => {
        this.list = res.data;
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.goods-list{
  padding: 0 0.2rem;
	.cover{
		width: 0.8rem;
		height: 0.8rem;
		border-radius: 10px;
	}
}
</style>